<template>
  <div>
    <TypeNav></TypeNav>
    <ListContainer></ListContainer>
    <Recommend></Recommend>
    <Rank></Rank>
    <Like></Like>
    <!--Home父组件：通过v-for遍历生成多个Floor组件-->
    <Floor v-for="(floor) in floorList" :key="floor.id" :floorInfo="floor"></Floor>
    <Brand></Brand>
  </div>
</template>
<script>
import ListContainer from "@/pages/Home/ListContainer";
import Recommend from "@/pages/Home/Recommend";
import Rank from "@/pages/Home/Rank";
import Like from "@/pages/Home/Like";
import Floor from "@/pages/Home/Floor";
import Brand from "@/pages/Home/Brand";
//引入辅助函数
import { mapState } from 'vuex';
export default {
  name: "Home",
  components: {
    ListContainer,
    Recommend,
    Rank,
    Like,
    Floor,
    Brand,
  },
  //Home组件的组件挂载完毕，生命周期函数，通过Vuex发请求，获取Floor组件数据
  mounted () {
    // 派发获取floor组件数据的action
    this.$store.dispatch('getFloorList');
    // 派发获取用户信息的actin 
    this.$store.dispatch('getUserInfo')
  },
  
  computed:{
    ...mapState({
       floorList:state=>state.home.floorList
    })
  }
};
</script>

<style scoped>
</style>
